package com.kgt.crud.service;

import com.kgt.crud.bean.Employee;
import com.kgt.crud.bean.EmployeeExample;
import com.kgt.crud.dao.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeService {

    @Autowired
    private  EmployeeMapper employeeMapper;

    public List<Employee>  getAll(){
        EmployeeExample employeeExample=new EmployeeExample();
        EmployeeExample.Criteria or = employeeExample.or();



        List<Employee> employees = employeeMapper.selectByExampleWithDept(null);



        return employees;
    }

    public boolean checkuser(String empName) {
        EmployeeExample employeeExample=new EmployeeExample();
        EmployeeExample.Criteria criteria = employeeExample.createCriteria();
        criteria.andEmpNameEqualTo(empName);
        long l = employeeMapper.countByExample(employeeExample);

        return l==0;
    }

    public int saveEmp(Employee employee) {
        return  employeeMapper.insertSelective(employee);



    }
}

